package com.um.swing.dialog;

import com.sun.awt.AWTUtilities;
import com.um.swing.MainView;
import com.um.swing.common.util.WindowUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;


/**
 * 名称：点位设置弹窗
 * 创建人：袁泉
 * 创建时间：2022年05月02日23:24:06
 */
public class JPostionSettingDialog extends JDialog {

    private static final long serialVersionUID = 2914192200129777056L;

    public static final Dimension W_SIZE = new Dimension(272, 295);
    public static final Font W_FONT = new Font("Arial", Font.BOLD, 18);

    private static JPostionSettingDialog __instance = null;

    private String str = "加载中...";

    public static JPostionSettingDialog getInstance() {
        if (__instance == null)
            __instance = new JPostionSettingDialog();
        return __instance;
    }

    private JPostionSettingDialog() {
        super(MainView.getInstance());
        WindowUtil.setIcon(this, null);

//        setUndecorated(true);
        setPreferredSize(W_SIZE);
        setSize(W_SIZE);
        setLocationRelativeTo(null);
        setVisible(false);
        JTextField sVField = new JTextField("开发中..");
        JTextField sHField = new JTextField("请输入");
        this.add(sVField);
        this.add(sHField);

//        AWTUtilities.setWindowOpacity(this, 0.6f);
//        AWTUtilities.setWindowShape(this, new RoundRectangle2D.Float(0, 0, getWidth(), getHeight(), 10, 10));
    }

//	@Override
//	public void paint( Graphics g ) {
//		Graphics2D g2 = ( Graphics2D ) g;
//		//g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6F));
//		g2.setColor(new Color(255, 0, 0));
//		g2.fill3DRect(0, 0, this.getWidth(), this.getHeight(), true);
//		g2.setColor(Color.WHITE);
//
//		if ( str != null ) {
//			g2.setFont(W_FONT);
//			FontMetrics fm = this.getFontMetrics(W_FONT);
//			g2.drawString(str,
//					( this.getWidth() - fm.stringWidth(str) ) / 2,
//					this.getHeight() / 2 + 5);
//		}
//	}

//	public void hiddenDialog() {
//		SwingUtilities.invokeLater(new Runnable(){
//			@Override
//			public void run() {
//				setVisible(false);
//			}
//		});
//	}
//
//	public void showDialog() {
//		SwingUtilities.invokeLater(new Runnable(){
//			@Override
//			public void run() {
//				setVisible(true);
//			}
//		});
//	}

}
